package com.lxl.edu.info.manager.dao;

import com.lxl.edu.info.manager.daomain.Student;


public class StudentDao {
    private static Student[] stus = new Student[5];

    public static Student[] findAllStudent() {
        return stus;
    }


    public boolean addStudent(Student st) {
        //创建学生对象数组


        //添加学生到数组

        //定义变量index为-1，假设数组已经全部存满，没有null的元素
        int index = -1;
        //遍历数组取出每一个元素，判断是否是null
        for (int i = 0; i < stus.length; i++) {
            Student student = stus[i];
            //如果为null，
            if (student == null) {
//                让index变量记录当前索引位置，
                index = i;
//                并使用break结束循环遍历
                break;
            }
        }
        if (index == -1) {
            return false;
        } else {
            stus[index] = st;
            return true;
        }


        //返回是否添加成功的boolean类型状态
    }

   /* public  Student[] findAllStudent() {

        return stus;
    }*/

}
